var deleteDuplicates = function(head) {
    let head1 = head;
    let head2 = null;
    while((head1 != null) && (head1.next != null)){
        head2 = head1;
        while(head2.next != null){
            if(head2.val == head2.next.val){
                head2 = head2.next;
            }else{
                break;
            }
        }
        head1.next = head2.next;
        head1 = head1.next;
    }
    return head;
};